s = "dashkdjashkhdkasjh"
# 用字典
# d = {}
# for i in s:
#     if not d.get(i):  # 如果没有值
#         d[i] = 1
#     else:
#         d[i] = d[i] + 1
# print(d)

# from collections import Counter
# print(Counter(s))

s = "中"
print(ord(s))
# unicode  48 0  65 A  97 a
"""
    编码：
        a b c d  A B 1234  ,.? +-     不超过255
        1个字节 8bit 位
        0000 0000    1111 1111
        
        ASCII 编码   1个字节
        unicode 编码--->万国码  4个字节
            utf-8 是unicode一种实现 1-4字节
            utf-16
        GBK  国标  
        GB2312
"""

# 字符串方法
s = "abca"
print(s.index("a"))  # 0
print(s.count("a"))  # 2
print("-".join(s))

# l = ["a","b","c"]
# s1 = ""
# for i  in l:
#     s1+=i
# print(s1)
# print("".join(l))

# s1 = "a-b-c"
# print(s1.split("-"))

print(s.replace("a", "A"))
print(s.replace("a", "A", 1))  # 只替换一次

# s2 = " abc  "
# print(s2)
# print(s2.strip())# 去掉两端空格

# print(s.find("d"))  # 找不到-1
# print(s.index("d"))  # 找不到报错

# print(s.startswith("a"))
# print(s.endswith("b"))

# print(s.center(50,"*"))

s = "1"
# s = "10"
print(s.zfill(2))

s = "abca"
print(s.rindex("a"))  # 从右向左
